cmake_minimum_required(VERSION 3.16)
project(io_module VERSION 0.1.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(agv_msgs REQUIRED)
find_package(agv_srvs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(common REQUIRED)
find_package(shared_parameters REQUIRED)

file(GLOB_RECURSE SRCS
  "src/*.cpp"
  "src/communication_interface/*.cpp"
)

include_directories(
  include
  include/communication_interface
  include/io_module
)

add_executable(agv_set_io 
  ${SRCS}
)

target_include_directories(agv_set_io PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
)

target_compile_definitions(agv_set_io PRIVATE
  AGV_IO_MODULE_BUILD_DLL
)

ament_target_dependencies(agv_set_io
  rclcpp
  std_msgs
  agv_msgs
  agv_srvs
  std_srvs
  common
)

install(TARGETS agv_set_io
  RUNTIME DESTINATION lib/${PROJECT_NAME}
)

install(TARGETS agv_set_io
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
)

install(DIRECTORY include/ 
  DESTINATION include
)

install(DIRECTORY launch/
  DESTINATION share/${PROJECT_NAME}/launch
)

ament_export_include_directories(include)
ament_export_dependencies(
  rclcpp
  std_msgs
  agv_msgs
  agv_srvs
  std_srvs
  common
)

ament_package()